package lms.dwr.demo.service;

import lms.dwr.demo.common.ServiceException;
import lms.dwr.demo.model.ModelUser;
import lms.dwr.demo.web.component.pagination.PaginationSupport;

/**
 * The account service
 * 
 * @author Jeccy.Zhao
 *
 */
public interface ServiceUser 
extends ServiceBase
{
	/**
	 * Save/updates the account entity and
	 * returns the id after operation succeed.
	 * 
	 * @param account
	 *          the account entity model
	 * @return the entity id after operation
	 * @throws ServiceException
	 */
	String saveOrUpdate(final ModelUser account) 
			throws ServiceException;
	
	/**
	 * Validates the activation code with the specified account name
	 * 
	 * @param accountName
	 *            the account name
	 * @param activationCode
	 *            the account activation code
	 * @return true if the activation code valid with the account name
	 * @throws ServiceException
	 */
	boolean isActivationCodeValid (String accountName, 
			String activationCode) throws ServiceException;
	
	/**
	 * Removes the account entity by id
	 * 
	 * @param id
	 *         the account entity id
	 * @return true if account removes succeed; false otherwise.
	 * @throws ServiceException
	 */
	boolean removeAccount(final String id)
			throws ServiceException;
	
	/**
	 * Removes the account entity by model
	 * 
	 * @param account
	 *          the account entity model
	 * @return true if account removes succeed; false otherwise
	 * @throws ServiceException
	 */
	boolean removeAccount(final ModelUser account)
			throws ServiceException;
	
	/**
	 * Obtains the account entity 
	 * with the specified user name and password
	 * 
	 * @param userName
	 *          the account user name
	 * @param password
	 *          the account user password
	 * @return the account entity model
	 * @throws ServiceException
	 */
	ModelUser getAccountByUserNameAndPwd(final String userName, final String password)
			throws ServiceException;
	
	/**
	 * Obtains the account entity
	 * with the specified account user name
	 * 
	 * @param userName
	 *           the account user name
	 * @return the account entity model
	 * @throws ServiceException
	 */
	ModelUser getAccountByUserName(final String userName)
			throws ServiceException;
	
	/**
	 * Obtains the account entity 
	 * with the specified account id.
	 * 
	 * @param id
	 *          the account entity id
	 * @return the account entity model
	 * @throws ServiceException
	 */
	ModelUser getAccountById(final String id)
			throws ServiceException;
	
	/**
	 * Obtains the account entities with pagination
	 * 
	 * @param account
	 *           the account entity model
	 * @param pageSize
	 *           the page size
	 * @param startIndex
	 *           the start index
	 * @param order
	 *           the ordered field name
	 * @param isDesc
	 *           the flag on DESC
	 * @return account entities with pagination
	 * @throws ServiceException
	 */
	PaginationSupport<ModelUser> getAccountPage(
			final ModelUser account, int pageSize, int startIndex, 
			final String order, final Boolean isDesc) throws ServiceException;
}
